package com.google.bitcoin.core;

import com.google.bitcoin.db.DoubleSpendException;
import java.util.List;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;

import java.io.OutputStream;
import java.io.File;
import java.io.IOException;

import java.math.BigInteger;

public interface WalletInterface
{
    public void reorganize(List<StoredBlock> oldBlocks, List<StoredBlock> newBlocks) throws VerificationException;

    public boolean isTransactionRelevant(Transaction tx, boolean includeDoubleSpending) throws ScriptException;

    public void receiveFromBlock(Transaction tx, StoredBlock block, BlockChain.NewBlockType blockType) 
        throws VerificationException, ScriptException;

    public Transaction getTransaction(Sha256Hash hash);
    public Transaction getTransaction(Sha256Hash hash, int connected_out_levels);

    public PeerEventListener getPeerEventListener();

    public Collection<Transaction> getPendingTransactions();
    public Collection<TransactionOutput> getUnspentOutputs();
    public Collection<TransactionOutput> getUnspentOutputs(Address addr);
    public Set<Transaction> getTransactions(boolean includeDead, boolean includeInactive);

    public void commitTx(Transaction tx) throws VerificationException, DoubleSpendException;

    public void receivePending(Transaction tx) throws VerificationException, ScriptException;

    public BigInteger getBalance();
    public BigInteger getBalance(BalanceType balanceType);
    public BigInteger getBalance(BalanceType balanceType, Address addr);
    public BigInteger getBalance(BalanceType balanceType, HashSet<Address> addrs);

    public Iterable<ECKey> getKeys();
    public ECKey findKeyFromPubHash(byte[] pubkeyHash);

    public boolean isPubKeyHashMine(byte[] pubkeyHash);
    public void addKey(ECKey key);

    public void saveToFileStream(OutputStream f) throws IOException;
    public void saveToFile(File f) throws IOException;

    public long getEarliestKeyCreationTime();

}


